home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / windows5 / xwinc100.zip / CONTRIB-.00 / CONTRIB- / contrib / examples / Xaw / xpanner.c < prev    next >
C/C++ Source or Header  |  1991-01-22  |  3KB  |  98 lines

  1. /*
  2.  * $XConsortium: xpanner.c,v 1.3 91/01/22 19:55:25 gildea Exp $
  3.  *
  4.  * Copyright 1990 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Jim Fulton, MIT X Consortium
  24.  */
  25.  
  26. #include <stdio.h>
  27. #include <X11/Intrinsic.h>
  28. #include <X11/StringDefs.h>
  29. #include <X11/Xaw/Cardinals.h>
  30. #include <X11/Xaw/Panner.h>
  31.  
  32. char *ProgramName;
  33.  
  34. static String fallback_resources[] = {
  35.     "*Panner.CanvasWidth: 1200",
  36.     "*Panner.CanvasHeight: 1000",
  37.     "*Panner.SliderWidth: 400",
  38.     "*Panner.SliderHeight: 500",
  39.     NULL
  40. };
  41.  
  42. static XrmOptionDescRec options[] = {
  43.     { "-cw", "*Panner.CanvasWidth", XrmoptionSepArg, NULL },
  44.     { "-ch", "*Panner.CanvasHeight", XrmoptionSepArg, NULL },
  45.     { "-sw", "*Panner.SliderWidth", XrmoptionSepArg, NULL },
  46.     { "-sh", "*Panner.SliderHeight", XrmoptionSepArg, NULL },
  47.     { "-sc", "*shadowColor", XrmoptionSepArg, NULL },
  48.     { "-bs", "*backgroundStipple", XrmoptionSepArg, NULL },
  49. };
  50.  
  51. static void usage ()
  52. {
  53.     fprintf (stderr, "usage:  %s [-options ...]\n", ProgramName);
  54.     fprintf (stderr, "where options include:\n");
  55.     fprintf (stderr, "    -cw number        canvas width\n");
  56.     fprintf (stderr, "    -ch number        canvas height\n");
  57.     fprintf (stderr, "    -sw number        slider width\n");
  58.     fprintf (stderr, "    -sh number        slider height\n");
  59.     fprintf (stderr, "    -bs string        background stipple name\n");
  60.     fprintf (stderr, "\n");
  61.     exit (1);
  62. }
  63.  
  64. static void report (w, closure, data)
  65.     Widget w;
  66.     XtPointer closure;
  67.     XtPointer data;
  68. {
  69.     XawPannerReport *rep = (XawPannerReport *) data;
  70.     printf ("slider %dx%d+%d+%d in canvas %dx%d\n", 
  71.         rep->slider_width, rep->slider_height,
  72.         rep->slider_x, rep->slider_y, 
  73.         rep->canvas_width, rep->canvas_height);
  74. }
  75.  
  76. main (argc, argv)
  77.     int argc;
  78.     char **argv;
  79. {
  80.     Widget toplevel;
  81.     XtAppContext app;
  82.     Arg args[1];
  83.     static XtCallbackRec cbrec[2] = {{ report, NULL }, { NULL, NULL }};
  84.  
  85.     ProgramName = argv[0];
  86.  
  87.     toplevel = XtAppInitialize (&app, "XPanner", options, XtNumber(options),
  88.                 &argc, argv, fallback_resources,
  89.                 NULL, ZERO);
  90.     if (argc != 1) usage ();
  91.  
  92.     XtSetArg (args[0], XtNcallback, cbrec);
  93.     (void) XtCreateManagedWidget ("panner", pannerWidgetClass, toplevel,
  94.                   args, ONE);
  95.     XtRealizeWidget (toplevel);
  96.     XtAppMainLoop (app);
  97. }
  98.